<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/19
 * Time: 16:08
 */

namespace app\ext\controller;

use app\ext\service\TodoService;
use think\Controller;

class Todo extends Controller
{
    public function index()
    {
        $page = input('p')?:1;
        $todoService = new TodoService();
        $todoList = $todoService->todoList($page);
        $this->assign('title','ToDo');
        return view('index',['list'=>$todoList]);
    }

    public function add()
    {
        $todoService = new TodoService();
        $add_res = $todoService->addTodo();
        $add_res && $this->success($add_res);
        $this->error('添加失败');
    }

    public function del()
    {
        $todoService = new TodoService();
        $res = $todoService->del();
        $res && $this->success('删除成功');
        $this->error('删除失败');
    }
}